import { authedApi } from '../utils/axios'
// 获取算法管理列表
export function getModelList(project_id, params = {}) {
  return authedApi.get(`/projects/${project_id}/models/`, {params});
}
//新建算法
export function createModelData(project_id, params = {}) {
  return authedApi.post(`/projects/${project_id}/models/`, params);
}
// 判断该算法名称是否存在
export function titleExist(project_id, params = {}) {
  return authedApi.get(`/projects/${project_id}/models/is_title_exists/`,{params});
}
// 删除算法
export function deleteAlgData(project_id, model_id) {
  return authedApi.delete(`/projects/${project_id}/models/${model_id}`);
}
// 获取算法详情
export function getAlgDetail(project_id, model_id) {
  return authedApi.get(`/projects/${project_id}/models/${model_id}/`);
}
// 修改模型详情
export function putAlgDetailData(project_id, id, params = {}) {
  return authedApi.put(`/projects/${project_id}/models/${id}/`,params);
}
// 获取所有算法
export function getAlgAllList(project_id) {
  return authedApi.get(`/projects/${project_id}/models/all/`);
}
// 获取模型超参
export function getParameters(project_id,model_id) {
  return authedApi.get(`/projects/${project_id}/models/${model_id}/parameters/`);
}
// 获取任务管理
export function getRunsList(project_id,model_id) {
  return authedApi.get(`/projects/${project_id}/models/${model_id}/runs/`);
}
//获取所有任务列表
export function getAllRunsList(project_id,params={}) {
  return authedApi.get(`/projects/${project_id}/model_runs/`,{params});
}
//创建任务作业
export function createRuns(project_id,model_id, params = {}) {
  return authedApi.post(`/projects/${project_id}/models/${model_id}/runs/`, params);
}
// 停止训练任务
export function stopRuns(project_id,run_id, params = {}) {
  return authedApi.post(`/projects/${project_id}/model_runs/${run_id}/stop/`, params);
}
// 重启训练任务
export function restartRuns(project_id,run_id, params = {}) {
  return authedApi.post(`/projects/${project_id}/model_runs/${run_id}/restart/`, params);
}
// 删除训练任务
export function deleteRuns(project_id, model_id,run_id) {
  return authedApi.delete(`/projects/${project_id}/models/${model_id}/runs/${run_id}/`);
}
//获取训练任务详情
export function getRunsDetail(project_id, model_id ,run_id) {
  return authedApi.get(`/projects/${project_id}/models/${model_id}/runs/${run_id}/`);
}
//检查是否拥有仓库授权（gitee/gitlab）
export function checkUser(checkName,params = {}) {
  return authedApi.post(`/auth/${checkName}/check/`, params);
}
// 获取仓库授权地址（gitee/gitlab）
export function giteeAuthorize(checkName,params = {}) {
  return authedApi.post(`/auth/${checkName}/authorize_url/`, params);
}
// 获取训练任务详情中的事件数据
export function getRunsDetailEvents(project_id,run_id) {
  return authedApi.get(`/projects/${project_id}/model_runs/${run_id}/events/`);
}
//获取训练任务详情日志数据
export function getRunsDetailLog(project_id,run_id,filepath) {
  return authedApi.get(`/projects/${project_id}/model_runs/${run_id}/log/${filepath}`);
}
//获取训练任务详情评估数据
export function getRunsDetailMetrics(project_id,run_id) {
  return authedApi.get(`/projects/${project_id}/model_runs/${run_id}/metrics/`);
}
//获取算法下对应的训练作业
export function getModelAboutRuns(project_id,model_id) {
  return authedApi.get(`/projects/${project_id}/models/${model_id}/runs/all/`);
}
//创建模型
export function createModelApp(project_id,params = {}) {
  return authedApi.post(`/projects/${project_id}/model_repository/models/`, params);
}
export function getCreateModelAppList(project_id) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/`);
}
//获取创建的模型详情信息
export function getModelAppDetail(project_id,repository_model_id) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/${repository_model_id}/`);
}
//获取仓库模型版本列表
export function getModelVersionsList(project_id,repository_model_id) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/${repository_model_id}/versions`);
}
//获取模型版本详情
export function getModelVersionsDetail(project_id,repository_model_id,version_id) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/${repository_model_id}/versions/${version_id}/`);
}
//获取注册模型详情
export function getCreateModelDetail(project_id,repository_model_id) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/${repository_model_id}/`);
}
//模型来源
export function getModelSource(project_id,model_id) {
  return authedApi.get(`/projects/${project_id}/models/${model_id}/runs/all/`);
}
//仓库新增模型版本
export function addModelVersion(project_id,repository_model_id,params) {
  return authedApi.post(`/projects/${project_id}/model_repository/models/${repository_model_id}/versions/`,params);
}
//删除创建的模型
export function deleteCreateModel(project_id,repository_model_id) {
  return authedApi.delete(`/projects/${project_id}/model_repository/models/${repository_model_id}/`);
}
//删除模型版本
export function deleteModelVersion(project_id, repository_model_id, version_id) {
  return authedApi.delete(`/projects/${project_id}/model_repository/models/${repository_model_id}/versions/${version_id}/`);
}
//文件列表获取接口
export function getFileList(project_id, repository_model_id, version_id,path) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/${repository_model_id}/versions/${version_id}/artifacts/?path=${path}`);
}
//文件下载
export function downFiles(project_id, repository_model_id, version_id, path) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/${repository_model_id}/versions/${version_id}/artifact_content/?path=${path}`);
}
//getReportData
export function getReportData(project_id, repository_model_id, version_id) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/${repository_model_id}/versions/${version_id}/metrics/`);
}
//新添加评估数据历史接口-用于显示单个评估数据的图表
export function getMetricHistory(project_id, repository_model_id, version_id,params) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/${repository_model_id}/versions/${version_id}/metric_history/`,{params});
}
//校验添加项目成员邮箱是否有效
export function isEmailUse(id,params = {}) {
  return authedApi.post(`/projects/${id}/members/validate/`,params);
}
//获取仓库模型版本参数
export function getModelVersionParameter(project_id, repository_model_id, version_id) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/${repository_model_id}/versions/${version_id}/params/`);
}
//获取仓库模型版本评估数据
export function getModelVersionEvaluationData(project_id, repository_model_id, version_id) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/${repository_model_id}/versions/${version_id}/metrics/`);
}
//训练作业中新建训练任务-训练任务名称校验
export function validateTraining(project_id,params={}) {
  return authedApi.get(`/projects/${project_id}/model_runs/is_title_exists/`, {params});
}
//模型应用->创建模型(模型名称校验)
export function validateModelName(project_id,params={}) {
  return authedApi.get(`projects/${project_id}/model_repository/models/is_title_exists/`, {params});
}
//错误日志
export function errorLog(project_id, repository_model_id, version_id) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/${repository_model_id}/versions/${version_id}/log/build_error.log/`);
}
//模型镜像重构
export function modelReconfiguration(project_id, repository_model_id, version_id) {
  return authedApi.post(`/projects/${project_id}/model_repository/models/${repository_model_id}/versions/${version_id}/rebuild/ `);
}



//模型部署
//模型部署-模型title是否存在
export function model_is_title_exists(project_id,params={}) {
  return authedApi.get(`/projects/${project_id}/models/is_title_exists/`, {params});
}
//模型部署-
// export function repositoryModelVersions(project_id,repository_model_id,params={}) {
//   return authedApi.get(`/projects/{project_id}/model_repository/models/${repository_model_id}/versions/`, {params});
// }
//模型部署-获取项目下所有的注册模型
export function getProjectRepositoryModels(project_id) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/all/`);
}
//模型部署-获取模型仓库版本
export function getProjectRepositoryModelsVersion(project_id,repository_model_id) {
  return authedApi.get(`/projects/${project_id}/model_repository/models/${repository_model_id}/versions/`);
}
//模型部署-获取模型部署队列
export function getModelQueues() {
  return authedApi.get(`/model_deployment_queues/`);
}
//模型部署
export function getModelDeployments(project_id,params={}) {
  return authedApi.post(`/projects/${project_id}/model_deployments/`, params);
}
//获取模型部署列表
export function getModelDeploymentsList(project_id,params={}) {
  return authedApi.get(`/projects/${project_id}/model_deployments/`, params);
}
//删除模型部署
export function deleteModelDeploy(project_id,id,params={}) {
  return authedApi.delete(`/projects/${project_id}/model_deployments/${id}/`, params);
}
//修改模型部署
export function editorModelDeployHandle(project_id,id,params={}) {
  return authedApi.put(`/projects/${project_id}/model_deployments/${id}/`, params);
}
//启动模型部署
export function startModelDeployHandle(project_id,id,params={}) {
  return authedApi.post(`/projects/${project_id}/model_deployments/${id}/start/`, params);
}
//确认停止模型部署
export function sureStopModelDeployHandle(project_id,id,params={}) {
  return authedApi.post(`/projects/${project_id}/model_deployments/${id}/stop/`, params);
}



//模型部署详情
export function getModelDevelopHandle(project_id,id,params={}) {
  return authedApi.get(`/projects/${project_id}/model_deployments/${id}/`, params);
}
//模型部署详情-事件接口-获取模型部署事件
export function getEventDataListHandle(project_id,id,params={}) {
  return authedApi.get(`/projects/${project_id}/model_deployments/${id}/events/`, params);
}
//模型部署详情-获取模型部署调用指南
export function getApiEndpointHandle(project_id,id,params={}) {
  return authedApi.get(`/projects/${project_id}/model_deployments/${id}/api_endpoint/`, params);
}
//模型部署详情-设置是否支持认证
export function setApiAuthHandle(project_id,id,params={}) {
  return authedApi.post(`/projects/${project_id}/model_deployments/${id}/set_api_auth/`, params);
}
//获取模型训练队列
export function getClusterQueueDataHandle() {
  return authedApi.get(`/model_run_queues/`);
}
//获取训练任务下AutoML算法id
export function getAutomlModeId(project_id) {
  return authedApi.get(`/projects/${project_id}/models/automl_model_id`);
}
//获取特征集路径
export function getFeaturesPaths(project_id,featuresId) {
  return authedApi.get(`/v2/projects/${project_id}/feature_set/${featuresId}/get_paths/`);
}
//模型详情配置更新界面
export function getConfigurationUpdateHandle(project_id,featuresId) {
  return authedApi.get(`/projects/${project_id}/model_deployments/${featuresId}/config_logs/`);
}
//模型部署-监控信息
export function getMonitorInfo(project_id,id) {
  return authedApi.get(`/projects/${project_id}/model_deployments/${id}/monitor/`);
}
